package com.dream.utils.date;

import java.util.HashMap;
import java.util.Map;

import com.dream.utils.exception.BusinessException;

/**
 * populate a date from  String to Date
 * @copyright evan
 * @author evan
 * @Revision
 * @date 2012/8/18
 */
public enum TimeType {
	YEAR(6),
	MONTH(5),
	WEEK(4),
	DAY(3),
	HOUR(2),
	MINITE(1), 
	SECOND(0) ;
	private final int value;
	private final static Map<TimeType,Long> map;
	static{
		map = new HashMap<TimeType,Long>(12);
		map.put(WEEK, 24L * 3600 * 1000 * 7);
		map.put(DAY,  24L * 3600 * 1000);
		map.put(HOUR, 3600L * 1000);
		map.put(MINITE, 60L*1000);
		map.put(SECOND, 1000L);
	}
	private TimeType(int val){
		value = val;
	}
	public int toInteger(){
		return value;
	}
	/**
	 * get million seconds
	 * @return
	 */
	public long getMillSeconds(){
		if(map.containsKey(this)){
			return map.get(this);
		}else{
			throw new BusinessException("Unsupport to get millsecond TimeType is " + this);
		}
	}
}
